package com.example.controller;

import com.example.common.Result;
import com.example.entity.UserInfo;
import com.example.service.WebService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class WebController {

    @Resource
    private WebService webService;

    /**
     * 默认请求接口
     */
    @GetMapping("/")
    public Result hello() {
        return Result.success();
    }


    /**
     * 用户登录接口
     */
    @PostMapping("/login")
    public Result login(@RequestBody UserInfo userInfo) {
        return webService.login(userInfo);
    }

    /**
     * 用户注册接口
     */
    @PostMapping("/register")
    public Result register(@RequestBody UserInfo userInfo) {
        return webService.register(userInfo);
    }
}